package org.msfj.admin.feign;

import org.msfj.admin.vo.HolidayVo;
import org.msfj.authority.client.configuration.ClientAutoConfiguration;
import org.msfj.common.model.CommonResult;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Date;
import java.util.List;

@FeignClient(value = "admin-service", configuration = ClientAutoConfiguration.class)
public interface HolidayApi {

    /**
     * 返回指定日期 n 个工作日（跳过设置的节假日）之后的日期
     *
     * @param startTime
     * @param workDay
     * @return
     */
    @RequestMapping("/api/holiday/afterDay")
    CommonResult<Date> workDayAfter(@RequestParam("startTime") Date startTime, @RequestParam("workDay") Integer workDay);

    /**
     * 计算某个日期几个小时之后的时间
     * @param startTime
     * @param limitHour
     * @return
     */
    @RequestMapping("/api/holiday/afterHour")
    CommonResult<Date> workHourAfter(@RequestParam("startTime") Date startTime, @RequestParam("limitHour") Integer limitHour);

    /**
     * 判断某天是否是节假日
     *
     * @param date
     * @return
     */
    @RequestMapping("/api/holiday/isHoliday")
    CommonResult<Boolean> isHoliday(@RequestParam("date") Date date);

    /**
     * 获取某年的所有节假日
     *
     * @param year
     * @return
     */
    @RequestMapping(value = "/api/holiday/getHolidaysByYear", method = RequestMethod.GET)
    CommonResult<List<HolidayVo>> getHolidaysByYear(@RequestParam("year") String year);
}
